#ifndef KINECTSNAPSHOTRECORDERFRAME_H
#define KINECTSNAPSHOTRECORDERFRAME_H

#ifdef KINECT

#include <QFrame>
#include <QTime>
#include <QMap>
#include <QVector>

#include "global.h"

#include "GUI/Troy/troyframe.h"
#include "GUI/layouts/flowlayout.h"

namespace Ui {
    class KinectSnapshotRecorderFrame;
}

/**
  * @brief The QFrame that lives inside the KinectSnapshotRecorderDialog and handles the recording configuration
  * and visual feedback.
  */
class KinectSnapshotRecorderFrame : public QFrame{
private:
    Q_OBJECT
    Ui::KinectSnapshotRecorderFrame *ui;
    QMap<int, TroyFrame*> _poses;
    FlowLayout* _flowLayout;

    int _frameSize;
public:
    explicit KinectSnapshotRecorderFrame(QWidget *parent = 0);
    ~KinectSnapshotRecorderFrame();
public slots:
    // Start and stop recording (serves mainly to reset the internal timer, to know what time different keyframes should
    // be registered for.)
    void started();
    void stopped();

    /**
      * @brief Adds the given MotionKeyFrame as one of the displayed poses (called snapshots by the other QFrame), and
      * associates it with the given int id.
      *
      * @param id
      * @param pose
      */
    void addPose(int id, MotionKeyFrame pose);
    /**
      * @brief Deletes a pose and removes it from the display.
      *
      * @param id
      */
    void deletePose(int id);

    /**
      * @brief Highlights the indicated pose to show that it has been detected, and is still seen.
      *
      * @param id
      */
    void startPose(int id);
    /**
      * @brief Clears the highlight on the indicated pose to show that it is no longer seen.
      *
      * @param id
      */
    void endPose(int id);

    /**
      * @brief Scales the pose to show how close of a match is detected to each one.
      *
      * @param id
      * @param closeness Float from 0 to 1 indicated how close of a match there is at present to the given pose.
      *  0 means no match, 1 means exact match.
      */
    void setPoseMatch(int id, float closeness);

signals:
    /**
      * @brief Fired to request a start from the recorder dialog.
      */
    void startRequested();
    /**
      * @brief Fired to request a stop from the recorder dialog.
      */
    void stopRequested();

private slots:
    void requestStart();
    void requestStop();
};

#endif

#endif // KINECTSNAPSHOTRECORDERFRAME_H
